﻿using System;
using System.Web;
using Nancy.Authentication.Basic;

namespace NancyBase.NancyAuthentication
{
    /// <summary>
    /// 实现IUserValidator接口。
    /// </summary>
    public class BasicUserValidator : IUserValidator
    {
        public System.Security.Claims.ClaimsPrincipal Validate(string username, string password)
        {
            if (username == "kinfar" && password == "kinfar.net")
            {
                return new System.Security.Claims.ClaimsPrincipal(new System.Security.Principal.GenericIdentity(username));
                //return new BasicUser() { UserName = username };
            }
            return null;
        }
    }

    /// <summary>
    /// 实现IUserIdentity接口。
    /// </summary>
    public class BasicUser : System.Security.Claims.ClaimsPrincipal
    {
        public string UserName { get; set; }

        public System.Collections.Generic.IEnumerable<string> Claims { get; set; }
    }
}
